<!-- #INCLUDE Virtual="/lib.asp" -->
<!-- #INCLUDE Virtual="/lib_gen.asp" -->

<%
dim rss, objXMLDom, objXMLdata
dim rssTitle, rssInhoud
const rssError = "Geen JIRA data ontvangen"
rssInhoud = rssError

Dim http: Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")

Set objXMLDom = Server.CreateObject("Microsoft.XMLDOM")
objXMLDom.preserveWhiteSpace = true
objXMLDom.async = false
objXMLDom.resolveExternals = false

objXMLDom.setProperty "SelectionNamespaces", "xmlns=""http://www.w3.org/2005/Atom"" xmlns:atlassian=""http://streams.atlassian.com/syndication/general/1.0"" xmlns:thr=""http://purl.org/syndication/thread/1.0"" xmlns:activity=""http://activitystrea.ms/spec/1.0/"""

'on error resume next

cacheAge = DateDiff("n", application("jira_cache_001_timestamp"), now()) 
if cacheAge > 59 or application("jira_cache_001") = "" or request("cache") = "no" then
	'Always specify username/password here, for fail safety
	http.open "GET", "https://issues.onehippo.com/sr/jira.issueviews:searchrequest-xml/15332/SearchRequest-15332.xml?tempMax=500&field=summary&field=updated&field=reporter", False,"",""
	http.setRequestHeader "Authorization", "Basic " & application("Jira_Key") 'Base64Encode("username:password")
	http.send
	application("jira_cache_001") = http.responseText
	application("jira_cache_001_timestamp") = now()
end if
rss = application("jira_cache_001")

objXMLDom.loadXML(rss)
Set objXMLdata = objXMLDom.documentElement

max = objXMLdata.selectNodes("//item").length
i = random(0, max-1)
set node = objXMLdata.selectNodes("//item").item(i)

dim story, key, updated, reporter
story = node.selectSingleNode("summary").text
key = node.selectSingleNode("key").text
updatedArr = split(node.selectSingleNode("updated").text, " ")
updated = updatedArr(1) & " " & updatedArr(2) & " " & updatedArr(3)
reporter = node.selectSingleNode("reporter").text
if rssInhoud = rssError then rssInhoud = ""

rssInhoud = "<div class=""textfill"" style=""width: 100%; height: 70%""><span>" & server.htmlEncode(story) & "</span></div>" & vbcrlf
rssInhoud = rssInhoud & "<span class=""jira-info"">" & key & " - " & updated & " - " & reporter & "</span>"
rssInhoud = rssInhoud & "<script>" & vbcrlf & "$(function(){ $('.textfill').textfill({ maxFontPixels: 1024 }); });" & vbcrlf & "</script>"

call generatePage(request("preview"), request.querystring("nextpage"), "Herinnert u zich deze nog?", rssImage, rssInhoud)

%>